home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
sound
/
sample20.zip
/
SAMPLER.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1989-05-20
|
55KB
|
1,266 lines
Program analog_sound_sampler_with_editor;
{$A+,B-,D-,E+,F-,I+,L+,N-,O+,R-,S+}
{$M 16384,0,655360}
{ $define debug}
{$ifdef debug}
{$r+}
{$endif}
{$v-}
Uses
dos, crt, graph, rm, menus, fonts, drivers, mousfunc, turbmous,printer;
{ $define pwm}
{$define sample}
{$l samplasm}
Const
{$ifndef pwm}
titlestring = 'Sampler V2.0 (C) R.McKenzie 1989';
{$endif pwm}
{$ifdef pwm}
titlestring = 'PWM Sampler 2.0 (C) R.McKenzie 1989';
{$endif pwm}
(*
(C) Copyright 1989 by Rowan McKenzie
You may copy these files or use the source code only
for non-profit purposes. Please contact me if you wish to use any
part of the package for commercial purposes.
Rowan McKenzie
35 Moore Ave,
Croydon 3136
Vic, Australia
This program allows the manipulation and replay with chromatic intervals of
digital sound samples from the keyboard using a guitar fretboard or piano
keyboard layout. Pitch is determined by a fractional increment technique
and played through a D/A converter connected to a parallel port or through
the PC speaker using Pulse Width Modulation.
To create the PWM speaker version, define pwm above, change the pwm
definition in the samplasm.asm file to true, reassemble samplasm.asm,
and recompile this file.
To create the D/A version, define da above, change the pwm
definition in the samplasm.asm file to false, reassemble samplasm.asm,
and recompile this file.
To use the D/A version, an 8 bit D/A converter will need to be connected
to the parallel printer port named in the SAMPLER.CNF file.
To use the sample facility an autotriggering A/D converter will need be
appear at the same port address as the D/A converter, and define sample *)
Const cnffilename = 'sampler.cnf';
clipboardfilename = '.\sampler.clp';
lpt1 = $3bc; {might be wrong order?}
lpt2 = $378;
lpt3 = $278;
default_samplerate = 27; {initial sample rate=27kHz}
blocksize = 4096; {size of blocks for blockread/write}
bufflength = $fe00; {sample buffer size (<64k-16)}
{NOTE: this is the absolute minimum size
allowed here if compatibility between
versions is to be maintained}
maxbeats = 500; {no. song elements allowed}
maxjumps = 20; {no. jumps allowed inside songs}
maxsymbols = 15; {no. symbols in songs allowed}
maxfiles = 301; {no. files allowed in directory list (set
according to how many will fit on directory
display +1)}
bigemptystring = ' ';
esc = #$1b;
introdelay = 700; {delay for user to read intro screen(x10ms)}
dialogbcolor = red;
dialogcolor = white;
clickbcolor = red;
clickcolor = white;
screencolor = green;
dirbcolor = green;
dircolor = black;
dirhcolor = white;
panelcolor = lightgreen;
wavecolor = white;
waveboxcolor = lightred;
hotcolor = white;
hotbcolor = lightblue;
titlecolor = black;
tuningbcolor = blue;
tuningcolor = white;
timerbcolor = green;
timercolor = white;
drawcolor = yellow;
cornersize = 20; {size of corner arc}
arrowxsize = 8; {width of arrow pointers}
arrowysize = 9; {height " }
arrowxoff = 4; {offset to center of arrow (arrowxsize div 2)}
arrowpoints = 8; {no. points in arrow}
{patterns for arrow pointers}
uparrowshape : Array[1..arrowpoints] Of pointtype =
((x : 4; y : 0), (x : 0; y : 4), (x : 3; y : 4), (x : 3; y : 9),
(x : 5; y : 9), (x : 5; y : 4), (x : 8; y : 4), (x : 4; y : 0));
downarrowshape : Array[1..arrowpoints] Of pointtype =
((x : 104; y : 9), (x : 100; y : 5), (x : 103; y : 5), (x : 103; y : 0),
(x : 105; y : 0), (x : 105; y : 5), (x : 108; y : 5), (x : 104; y : 9));
tuningshapepoints = 4;
tuningrshape : Array[1..tuningshapepoints] Of polypoint =
((x : 10; y : 8), (x : 0; y : 12), (x : 0; y : 4), (x : 10; y : 8));
tuninglshape : Array[1..tuningshapepoints] Of polypoint =
((x : 0; y : 8), (x : 10; y : 12), (x : 10; y : 4), (x : 0; y : 8));
introyoff = 3; {intro information position}
plotxoffset = arrowxoff; {indent from edge of screen for wave}
dirnamefieldwidth = 14; {field width for directory names}
{modified codes to represent special keys in one byte}
spctrl = #128; splshift = #129; sprshift = #130; spalt = #131; spcaps = #132;
spnum = #133; spscroll = #134; sphome = #135; spsys = #136; spuparrow = #137;
sppgup = #138; spprtsc = #139; spleftarrow = #140; sp5 = #141;
sprightarrow = #142; spminus = #143; spend = #144; spdownarrow = #145;
sppgdn = #146; spplus = #147; spins = #148; spdel = #149; spf1 = #151;
spf2 = #152; spf3 = #153; spf4 = #154; spf5 = #155; spf6 = #156; spf7 = #157;
spf8 = #158; spf9 = #159; spf10 = #160;
{the following arrays map the keyboard to a set of notes (guitar or piano)
where -13 is an invalid letter}
Type kbdmaptype = Array[''''..']'] Of Integer;
Const kbdmapguitar : kbdmaptype =
( {'} 3, -13, -13, -13, -13, -5, 13, -4, -3, 12, 3, 4, 5, 6, 7, 8,
9, 10, 11, -13, 2, -13, 14, -13, -13, -13,
{A} -7, -8, -10, -5, 0, -4, -3, -2, 5, -1, 0, 1, -6, -7, 6, 7,
-2, 1, -6, 2, 4, -9, -1, -11, 3, -12, 8, 15, 9);
kbdmappiano : kbdmaptype =
( {'} 10, -13, -13, -13, -13, 5, 20, 7, 9, 18, 3, -13, 6, 8, 10, -13,
13, 15, -13, -13, 8, -13, 22, -13, -13, -13,
{A} -13, 0, -3, -4, 7, -2, -13, 1, 16, 3, -13, 6, 4, 2, 17, 19, 4,
9, -6, 11, 14, -1, 5, -5, 12, -7, 21, -13, 23);
{the following table maps scan codes to ascii values}
scanmap : Array[0..255] Of Char =
( {0} #0, esc, '1', '2', '3', '4', '5', '6', '7', '8',
{10} '9', '0', '-', '=', #8, #9, 'Q', 'W', 'E', 'R',
{20} 'T', 'Y', 'U', 'I', 'O', 'P', '[', ']', #13, spctrl,
{30} 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';',
{40} '''', '`', splshift, '\', 'Z', 'X', 'C', 'V', 'B', 'N',
{50} 'M', ',', '.', '/', sprshift, #0, spalt, ' ', spcaps, spf1,
{60} spf2, spf3, spf4, spf5, spf6, spf7, spf8, spf9, spf10, spnum,
{70} spscroll, sphome, spuparrow, sppgup, spminus, spleftarrow, sp5,
sprightarrow, spplus, spend,
{80} spdownarrow, sppgdn, spins, spdel, #0, #0, #0, #0, #0, #0,
{90} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
{100} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
{110} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
{120} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
{130} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
{140} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
{150} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
{160} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
{170} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
{180} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
{190} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
{200} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
{210} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
{220} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
{230} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
{240} #0, #0, #0, #0, #0, #0, #0, #0, #0, #0,
{250} #0, #0, #0, #0, #0, #0);
Type
bufferp = ^buffertype;
buffertype =
Array[0..bufflength] Of Byte; {holds samples, plus overflow space}
dummyp = ^dummytype;
dummytype = Array[1..128] Of Byte; {overflow area for buffers}
directory_type = Array[1..maxfiles] Of String[12]; {holds directory entries}
songentry = Record {holds one entry of a song file}
note : R